java如何使此方法可重用?
我有两个类使用类似的方法:
method classA() {
some variable initialization
get this common interface In
try {
do something
In.methodAA();
catch () {
do something
}
}
method classB() {
some variable initialization
get this common interface In
try {
do something
In.methodBB()
catch () {
do something
}
}
如果可能的话,我想在父类中放一个方法,因为主要的区别是在接口上调用的方法。如何实现这一点
我用的是java7
谢谢!
# 1 楼答案
我将使用由a和B类实现的公共接口
用法
# 2 楼答案
我会使用第三个实用程序类